import requests
#新建员工管理模块接口类

class EmpMangager():
    #封装员工添加接口
    @classmethod
    def emp_add(cls,headersdata,jsondata):
        # headersdata = {"Content-Type": "application/json", "Authorization": "f8bcdf26-717d-417f-a772-3215907d3d90"}
        # jsondata = {"username": "张三你好", "mobile": "18036475678", "workNumber": "478589"}
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/user", headers=headersdata, json=jsondata)
        print(resp.json())
        return resp

    #封装员工查询接口
    @classmethod
    def emp_search(cls,empId,headersdata):
        # headersdata = {"Authorization": "f8bcdf26-717d-417f-a772-3215907d3d90"}
        resp = requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/"+empId, headers=headersdata)
        print(resp.json())
        return resp

    #封装员工修改接口
    @classmethod
    def emp_update(cls,empID,headersdata,jsondata):
        # headersdata= {"Content-Type": "application/json", "Authorization": "f8bcdf26-717d-417f-a772-3215907d3d90"}
        # jsondata = {"username": "张三丰"}
        resp = requests.put(url="http://ihrm2-test.itheima.net/api/sys/user/"+empID, headers=headersdata,
                             json=jsondata)
        print(resp.json())
        return resp

    #封装员工删除接口
    @classmethod
    def emp_delete(cls,empId,headersdata):
        # headersdata = {"Authorization": "f8bcdf26-717d-417f-a772-3215907d3d90"}
        resp = requests.delete(url="http://ihrm2-test.itheima.net/api/sys/user/"+empId,
                                headers=headersdata)
        print(resp.json())
        return resp


